﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.29    风控审批项目综合认定信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_ADU_RISKCONTROLPRO: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_ADU_RISKCONTROLPRO()
		{}
		#region Model
		private long _id;
		private long _proid;
		private long _riskconid;
		private string _datatype;
		private string _datatypename;
		private string _datacontent;
		private int _datasortno;
		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 立项申请记录IDTb_app_proinfo.id
		/// </summary>
		[DataMember]
		public long PROID
		{
			get{return _proid;}
			set{
				if ( _proid!= value)
				{
					 _proid = value;
					OnPropertyChanged("PROID");
				}
			}
		}
		/// <summary>
		/// 风控审批记录IDTB_Adu_RiskControl.ID
		/// </summary>
		[DataMember]
		public long RISKCONID
		{
			get{return _riskconid;}
			set{
				if ( _riskconid!= value)
				{
					 _riskconid = value;
					OnPropertyChanged("RISKCONID");
				}
			}
		}
		/// <summary>
		/// 数据项标识
		/// </summary>
		[DataMember]
		public string DATATYPE
		{
			get{return _datatype;}
			set{
				if ( _datatype!= value)
				{
					 _datatype = value;
					OnPropertyChanged("DATATYPE");
				}
			}
		}
		/// <summary>
		/// 数据项名称
		/// </summary>
		[DataMember]
		public string DATATYPENAME
		{
			get{return _datatypename;}
			set{
				if ( _datatypename!= value)
				{
					 _datatypename = value;
					OnPropertyChanged("DATATYPENAME");
				}
			}
		}
		/// <summary>
		/// 数据项内容
		/// </summary>
		[DataMember]
		public string DATACONTENT
		{
			get{return _datacontent;}
			set{
				if ( _datacontent!= value)
				{
					 _datacontent = value;
					OnPropertyChanged("DATACONTENT");
				}
			}
		}
		/// <summary>
		/// 序号
		/// </summary>
		[DataMember]
		public int DATASORTNO
		{
			get{return _datasortno;}
			set{
				if ( _datasortno!= value)
				{
					 _datasortno = value;
					OnPropertyChanged("DATASORTNO");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

